Network attached memory using selective resource migration

ABSTRACT

Maintaining cache coherency in the presence of a network attached memory is disclosed. A computer system includes a plurality of physical nodes. An operating system is run collectively across the plurality of physical nodes. The physical nodes are configured to communicate with a network attached memory. Based at least in part on an operation to be performed with respect to page on a first physical node included in the plurality of physical nodes, the network attached memory is configured to receive a message. The network attached memory is configured to perform an action based at least in part on the received message.

CROSS REFERENCE TO OTHER APPLICATIONS

This application claims priority to U.S. Provisional Patent ApplicationNo. 62/236,076 entitled NETWORK ATTACHED MEMORY USING SELECTIVE RESOURCEMIGRATION filed Oct. 1, 2015 which is incorporated herein by referencefor all purposes.

BACKGROUND OF THE INVENTION

One typical way in which flash memory is used is to simulate disks inservers. It would be beneficial to use flash memory in additional ways.Unfortunately, existing system software solutions for servers do notprovide mechanisms for using flash memory other than as disk storage.

BRIEF DESCRIPTION OF THE DRAWINGS

Various embodiments of the invention are disclosed in the followingdetailed description and the accompanying drawings.

FIG. 1 illustrates an embodiment of a computer system.

FIG. 2 illustrates the physical structure of the computer system as ahierarchy.

FIG. 3A depicts a virtualized computing environment in which multiplevirtual machines (with respective multiple guest operating systems) runon a single physical machine.

FIG. 3B depicts a virtualized computing environment in which multiplephysical machines collectively run a single virtual operating system.

FIG. 4A depicts an example of a software stack.

FIG. 4B depicts an example of a software stack.

FIG. 5 depicts an example of an operating system's view of hardware onan example system.

FIG. 6A depicts an example of a hyperthread's view of hardware on asingle node.

FIG. 6B depicts an example of a hyper-kernel's view of hardware on anexample system.

FIG. 7 depicts an example of an operating system's view of hardware onan example of an enterprise supercomputer system.

FIG. 8 illustrates an embodiment of a process for selectively migratingresources.

FIG. 9 illustrates an embodiment of a process for performinghierarchical dynamic scheduling.

FIG. 10 illustrates an example of an initial memory assignment andprocessor assignment.

FIG. 11 illustrates an updated view of the memory assignment and anunchanged view of the processor assignment.

FIG. 12 illustrates a memory assignment and an updated view of theprocessor assignment.

FIG. 13A illustrates an example embodiment of a system in which anetwork attached memory is used in selective resource migration.

FIG. 13B illustrates an example embodiment of a system in which anetwork-attached memory is used in selective resource migration.

FIG. 14 illustrates an example embodiment of a network-attached memoryappliance.

FIG. 15 is a diagram illustrating an embodiment of allocating a page.

FIG. 16 illustrates an example embodiment of internode communicationaccording to a cache coherency protocol.

FIG. 17 is a flow diagram illustrating an embodiment of a process formaintaining cache coherency in the presence of a network attachedmemory.

FIG. 18 is a flow diagram illustrating an embodiment of a process forzeroing pages.

DETAILED DESCRIPTION

The invention can be implemented in numerous ways, including as aprocess; an apparatus; a system; a composition of matter; a computerprogram product embodied on a computer readable storage medium; and/or aprocessor, such as a processor configured to execute instructions storedon and/or provided by a memory coupled to the processor. In thisspecification, these implementations, or any other form that theinvention may take, may be referred to as techniques. In general, theorder of the steps of disclosed processes may be altered within thescope of the invention. Unless stated otherwise, a component such as aprocessor or a memory described as being configured to perform a taskmay be implemented as a general component that is temporarily configuredto perform the task at a given time or a specific component that ismanufactured to perform the task. As used herein, the term ‘processor’refers to one or more devices, circuits, and/or processing coresconfigured to process data, such as computer program instructions.

A detailed description of one or more embodiments of the invention isprovided below along with accompanying figures that illustrate theprinciples of the invention. The invention is described in connectionwith such embodiments, but the invention is not limited to anyembodiment. The scope of the invention is limited only by the claims andthe invention encompasses numerous alternatives, modifications andequivalents. Numerous specific details are set forth in the followingdescription in order to provide a thorough understanding of theinvention. These details are provided for the purpose of example and theinvention may be practiced according to the claims without some or allof these specific details. For the purpose of clarity, technicalmaterial that is known in the technical fields related to the inventionhas not been described in detail so that the invention is notunnecessarily obscured.

FIG. 1 illustrates an embodiment of a computer system. System 100 isalso referred to herein as an “enterprise supercomputer” and a“mainframe.” In the example shown, system 100 includes a plurality ofnodes (e.g., nodes 102-108) located in close proximity (e.g., locatedwithin the same rack). In other embodiments, multiple racks of nodes(e.g., located within the same facility) can be used in the system.Further, the techniques described herein can also be used in conjunctionwith distributed systems.

The nodes are interconnected with a high-speed interconnect (110) suchas 10-gigabit Ethernet, direct PCI-to-PCI, and/or InfiniBand. Each nodecomprises commodity server-class hardware components (e.g., a blade in arack with its attached or contained peripherals). In the example shownin FIG. 1, each node includes multiple physical processor chips. Eachphysical processor chip (also referred to as a “socket”) includesmultiple cores, and each core has multiple hyperthreads.

As illustrated in FIG. 2, the physical structure of system 100 forms ahierarchy (from the bottom) of hyperthreads (230), cores (210-224),physical processor chips (202-208), and nodes (102-108 (with nodes 104,106, etc. omitted from the figure and represented as ellipses)). Thetree depicted in FIG. 2 is of a fixed size, defined by the hardwareconfiguration.

As will be described in more detail below, each enterprise supercomputer(e.g., system 100) runs a single instance of an operating system. Boththe operating system, and any applications, can be standard commerciallyavailable software and can run on system 100. In the examples describedherein, the operating system is Linux, however other operating systemscan also be used, such as Microsoft Windows, Mac OS X, or FreeBSD.

In a traditional virtualized computing environment, multiple virtualmachines may run on a single physical machine. This scenario is depictedin FIG. 3A. In particular, three virtual machines (302-306) are runningthree guest operating systems on a single physical machine (308), whichhas its own host operating system. In contrast, using the techniquesdescribed herein, multiple physical machines (354-358) collectively runa single virtual operating system (352), as depicted in FIG. 3B.

One example of a software stack is depicted in FIG. 4A. Such a stack maytypically be used in traditional computing environments. In the stackshown in FIG. 4A, an application (402) sits above a database engine(404), which in turn sits upon an operating system (406), underneathwhich lies hardware (408). FIG. 4B depicts a software stack used in someembodiments. As with the stack shown in FIG. 4A, an application (452)sits above a database engine (454), which in turn sits upon an operatingsystem (456). However, underneath the operating system and above thehardware is a layer of software (referred to herein as a hyper-kernel)that observes the system running in real time and optimizes the systemresources to match the needs of the system as it operates. Thehyper-kernel conceptually unifies the RAM, processors, and I/O (InputOutput resources for example Storage, Networking resources) of a set ofcommodity servers, and presents that unified set to the operatingsystem. Because of this abstraction, the operating system will have theview of a single large computer, containing an aggregated set ofprocessors, memory, and I/O. As will be described in more detail below,the hyper-kernel optimizes use of resources. The hyper-kernel can alsohelp optimize other I/O system resources such as networks and storage.In some embodiments, based on observations and profiles of runningsoftware, performance indicators (hints) are provided to upper layers(e.g., database management systems) about the dynamic performance of thesystem that can further improve overall system performance.

The hyper-kernel can be ported to all major microprocessors, memory,interconnect, persistent storage, and networking architectures. Further,as hardware technology evolves (e.g., with new processors, new memorytechnology, new interconnects, and so forth), the hyper-kernel can bemodified as needed to take advantage of industry evolution.

As shown in FIG. 4B, operating system 456 is running collectively acrossa series of nodes (458-462), each of which has a hyper-kernel running onserver hardware. Specifically, the operating system is running on avirtual environment that is defined by the collection of hyper-kernels.As will be described in more detail below, the view for operating system456 is that it is running on a single hardware platform that includesall of the hardware resources of the individual nodes 458-462. Thus, ifeach of the nodes includes 1 TB of RAM, the operating system will haveas a view that it is running on a hardware platform that includes 3 TBof RAM. Other resources, such as processing power, and I/O resources cansimilarly be collectively made available to the operating system's view.

FIG. 5 depicts an example of an operating system's view of hardware onan example system. Specifically, operating system (502) runs on top ofprocessors 504-508 and physical shared memory 510. As explained above,an operating system can run on either a traditional computing system oron an enterprise supercomputer such as is shown in FIG. 1. In eithercase, the view of the operating system will be that it has access toprocessors 504-508 and physical shared memory 510.

FIG. 6A depicts an example of a hyperthread's view of hardware on asingle node. In this example, a node has four hyperthreads denoted H1(602) through H4 (608). Each hyperthread can access all portions ofphysical shared memory 612. Physical shared memory 612 is linear,labeled location 0 through a maximum amount, “max.” The node alsoincludes three levels of cache (610).

FIG. 6B depicts an example of a hyper-kernel's view of hardware on anexample system. In this example, three nodes (652-656) are included inan enterprise supercomputer. Each of the three nodes has fourhyperthreads, a physical shared memory, and cache (i.e., each node is anembodiment of node 600 shown in FIG. 6A). A hyperthread on a given node(e.g., node 652) has a view that is the same as that shown in FIG. 6A.However, the hyper-kernel is aware of all of the resources on all of thenodes (i.e., the hyper-kernel sees twelve hyperthreads, and all of thephysical shared memory). In the example shown in FIG. 6B, a givenhyperthread (e.g., hyperthread 658, “H1-4”) is labeled with its nodenumber (e.g., “1”) followed by a hyperthread number (e.g., “4”).

FIG. 7 depicts an example of an operating system's view of hardware onan example of an enterprise supercomputer system. The operating systemsees a plurality of “virtualized processors” denoted in FIG. 7 as P1through Pmax (702). The virtualized processors correspond to the totalnumber of hyperthreads across all nodes included in the enterprisesupercomputer. Thus, using the example of FIG. 6B, if a total of twelvehyperthreads are present across three nodes, a total of twelvevirtualized processors would be visible to an operating system runningon the enterprise supercomputer. The operating system also sees“virtualized physical memory” (704) that appears to be a large,physical, linear memory of a size equal to the total amount of physicalmemory across all nodes.

As will be described in more detail below, the hyper-kernel dynamicallyoptimizes the use of cache memory and virtual processor placement basedon its observations of the system as it is running. A “virtualprocessor” is a computing engine known to its guest operating system,i.e., one that has some operating system context or state. As will bedescribed in more detail below, a “shadow processor” is an anonymousvirtual processor, i.e., one that had been a virtual processor but hasnow given up its operating system context and has context known only tothe hyper-kernel.

Resource Virtualization

Memory Virtualization

As explained above, in the physical configuration, each node has anarray of memory addresses representing locations in memory. As such, ina physical configuration with three nodes (e.g., as depicted in FIG.6B), there are three memory locations each of which has address0x123456. In contrast, in the virtual configuration, all memoryaddresses are unique and represent the sum total of all memory containedin those three nodes. In the virtual configuration, all memory isshared, and all memory caches are coherent. In some embodiments, memoryis further subdivided into a series of contiguous blocks, withmonotonically increasing memory addresses. In the examples describedherein, each page has 4K bytes of memory, however, other subdivisionscan also be used, as applicable. The term“blocks” is used herein todescribe contiguous arrays of memory locations. In some embodiments, the“blocks” are “pages.”

Processor Virtualization

A virtual processor (e.g., virtual processor 706 of FIG. 7), as seen bythe operating system, is implemented on a hyperthread in the physicalconfiguration, but can be location independent. Thus, while theoperating system thinks it has 500 processors running on a singlephysical server, in actuality it might have 5 nodes of 100 processorseach. (Or, as is shown in FIG. 6B, the operating system will think ithas twelve processors running on a single physical server.) Thecomputation running on a virtual processor is described either by thephysical configuration on a hyperthread when the computation is running,or in a “continuation,” when the virtual processor is not running (i.e.,the state of an interrupted or stalled computation).

As used herein, a “continuation” represents the state of a virtualprocessor. Each continuation:

-   -   Has processor state (i.e., saved registers, etc.).    -   Has a set of performance indicators that guide a scheduler        object with information about how to intelligently assign        continuations to leaf nodes for execution.    -   Has a virtual-processor identifier that indicates the processor        the operating system thinks is the physical processor to which        this continuation is assigned.    -   Has an event on which this continuation is waiting (possibly        empty).    -   Has a state which includes: “waiting-for-event” or “ready.”

I/O Virtualization

I/O systems observe a similar paradigm to processors and memory. Deviceshave a physical address in the physical configuration and virtualaddresses in the virtual configuration. When migrating computations(described in more detail below), if for example, there are memorybuffers associated with I/O operations, the I/O devices used will likelyperform better if they are co-located with the memory with which theyare associated, and can be moved accordingly.

Resource Maps

Resource maps are used to translate between virtual and physicalconfigurations. The following are three types of resource maps used byenterprise supercomputers in various embodiments.

A “physical resource map” is a table that describes the physicalresources that are available on each node. It contains, for example, thenumber and type of the processors on each node, the devices, the memoryavailable and its range of physical addresses, etc. In some embodiments,this table is read-only and is fixed at boot time.

An “initial virtual resource map” is fixed prior to the booting of theoperating system and describes the virtual resources that are availablefrom the point of view of the operating system. The configuration isreadable by the operating system. In some cases, it may be desirable toconfigure a system (from the viewpoint of the operating system) thatdoes not match, one-to-one, with the underlying hardware resources. Asone example, it may be desirable for the operating system to have morememory and fewer cores. This can be accomplished by changing the ratioof memory to cores, i.e., by modifying the initial virtual resource map.

A “current resource map” is created and maintained by each hyper-kernelinstance. This map describes the current mapping between the virtualresource map and the physical resource map from the point of view ofeach node. For each entry in the virtual resource map, a definition ofthe physical resources currently assigned to the virtual resources ismaintained. Initially (e.g., at boot time), the current resource map isa copy of the initial virtual resource map. The hyper-kernel modifiesthe current resource map over time as it observes the characteristics ofthe resource load and dynamically changes the mapping of physicalresources to virtual resources (and vice-versa). For example, thedefinition of the location of the Ethernet controller eth27 in thevirtualized machine may at different times refer to different hardwarecontrollers. The current resource map is used by the hyper-kernel todynamically modify the virtual hardware resource mappings, such as thevirtual memory subsystem, as required.

Resource Migration Overview

Using the techniques described herein, virtualized resources can bemigrated between physical locations. As explained above, the operatingsystem is provided with information about the virtualized system, butthat information need not agree with the physical system.

In the following example, suppose an enterprise supercomputer holds alarge in-memory database, larger than can fit into a single node. Partof the database is in a first node, “node1.” Suppose one of the cores ona different node, “node2,” is trying to access data that is owned bynode1 and that does not reside locally in a cache on node2. The core onnode2 will receive a memory access violation because it is trying toaccess data that it believes it should be able to access (but cannot).As will be described in more detail below, the exception is handled inthe hyper-kernel.

One way that the situation can be resolved is by moving the needed areaof memory to node2, and then returning control back to the operatingsystem (which, in turn, returns it back to the database system). Thesoftware can then proceed as intended (i.e., as if the access violationnever occurred).

In many cases, there may be one or more other cores in other nodes(e.g., “node3”) that are also trying to access the same area block ofmemory as needed by node2 above. Node3 might be attempting to access thesame data, or it might be accessing different data contained in thememory that was moved (also referred to as “false sharing”). The datacould be moved to node3, but if the core on node2 asks for the data asecond time, the data would need to be moved back to node2 (i.e.,potentially moving the data back and forth repeatedly), which can beslow and wasteful. One way to avoid moving data back and forth betweencores is to recognize that both cores and the associated block of datashould be co-located. Using the techniques described herein, the memoryand the computation can be migrated so that they reside on the samenode. Doing so will result in a higher likelihood of faster access todata, and a higher probability of sharing data stored in local caches.

When the access violation occurs, an event is triggered (in a systemdependent way) to which the hyper-kernel responds. One example of howsuch an event can be handled is by the invocation of a panic routine.Other approaches can also be used, as applicable. As will be describedin more detail below, the hyper-kernel examines the cause of the eventand determines an appropriate strategy (e.g., low level transaction) forhandling the event. As explained above, one way to handle the event isfor one or more blocks of hyper-kernel virtualized memory to betransferred from one node's memory to another node's memory. Thetransfer would then be initiated and the corresponding resource mapswould be updated. A continuation would be built poised to be placed in alocal table in shared memory called the event table (discussed below) sothat the next thing the continuation does when it is resumed would be toreturn control to the operating system after the transfer is completed.A decision could also be made to move the virtual processor to the nodethat contains the memory being requested or to move the virtualizedmemory (and its virtualized memory address) from one node to another. Invarious embodiments, the hyper-kernel makes three decisions whenhandling an event: which (virtual) resources should move, when to movethem, and to where (in terms of physical locations) they should move.

TidalTree

The physical hierarchical structure depicted in FIG. 2 has an analogoussoftware hierarchy comprising a set of “scheduler objects” (i.e., datastructures), each of which has a set of characteristics described below.The scheduler objects form a “TidalTree,” which is an in-memory treedata structure in which each node of the tree is a scheduler object.Each scheduler object corresponds to an element of the physicalstructure of the supercomputer (but not necessarily vice versa), sothere is one node for the entire machine (e.g., node 100 as shown inFIG. 2), one node for each physical node of the system (e.g., node 102as shown in FIG. 2), one node for each multicore socket on the physicalnodes that comprise the entire machine (e.g., node 202 as shown in FIG.2), one node for each core of each socket (e.g., node 210 as shown inFIG. 2), and one node for each hyperthread on that core (e.g., node 232as shown in FIG. 2).

Each scheduler object s:

-   -   Is associated with a physical component (e.g., rack, blade,        socket, core, hyperthread).    -   Except for the root of the tree, has a parent scheduler object        which is partly responsible for directing its operations (as        explained in more detail below).    -   Has a set of children each of which is a scheduler object. This        is the null set for a leaf (e.g., hyperthread) node. As        explained in more detail below, it is the responsibility of a        scheduler object s to manage and assign (or re-assign) work to        its children, and indirectly to its grandchildren, etc. (i.e., s        manages all nodes in the subtree rooted at s).    -   Has a work queue, which is a set of continuations (as described        earlier).    -   Has a (possibly empty) set of I/O devices that it also has the        responsibility to manage and assign (or re-assign) work.

Each node can potentially be associated with a layer of some form ofcache memory. Cache hierarchy follows the hierarchy of the tree in thesense that the higher the scheduler object is, the slower it willusually be for computations to efficiently utilize caches at thecorresponding level of hierarchy. The cache of a scheduler objectcorresponding to a physical node can be a cache of memory correspondingto that node. The memory on the physical node can be thought of as acache of the memory of the virtual machine.

Resource Migration—Additional Information

The hyper-kernel simulates part of the virtual hardware on which thevirtual configuration resides. It is an event-driven architecture,fielding not only translated physical hardware events, but soft events,such as receipt of inter-node hyper-kernel messages generated byhyper-kernel code running on other nodes.

As explained above, when an interrupt event significant to thehyper-kernel occurs, the hyper-kernel makes a decision of how to respondto the interrupt. Before control is returned to the operating system,any higher priority interrupts are recognized and appropriate actionsare taken. Also as explained above, the hyper-kernel can make threeseparate decisions: (1) which resources to migrate upon certain events,(2) when to migrate them, and (3) to where those resources should move.

In the following example, suppose a scheduler object “s” in a virtualmachine is in steady state. Each scheduler object corresponding to aphysical node has a set of physical processor sockets assigned to it.Hyperthreads in these sockets may or may not be busy. The physical nodealso has some fixed amount of main memory and a set of I/O devices,including some network devices. Scheduler object s, when correspondingto a node, is also responsible for managing the networks and other I/Odevices assigned to nodes in the subtree rooted at s. The following is adescription of how resources can migrate upon either synchronous orasynchronous events.

Migrations Triggered by Synchronous Events

In the following example, suppose there exists a leaf node schedulerobject s, and virtual processor p assigned to s. Leaf node scheduleobject s is assumed to be executing an application or operating systemcode on behalf of an application. Assuming the leaf node is not in aninfinite loop, p will eventually run out of work to do (i.e., stall) forsome reason (e.g., waiting for completion of an I/O operation, pagefault, etc.). Instead of allowing p to actually stall, the hyper-kerneldecides whether to move the information about the stalled computation tosome other node, making one of that other node's processors“responsible” for the stalled continuation, or to keep the“responsibility” of the stalled computation on the node and instead movethe relevant resources to the current node.

The stall is thus handled in either of two ways: either the computationis moved to the physical node that currently has the resource, or elsethe resource is moved to the physical node that has requested theresource. Example pseudo code for the handling of a stall is providedbelow (as the “OnStall” routine) in the “EXAMPLE ROUTINES” sectionbelow.

Decisions such as how to handle a stall can be dependent on many things,such as the order of arrival of events, the state of the computationrunning on the virtual machine, the state of the caches, the load on thesystem or node, and many other things. Decisions are made dynamically,i.e., based on the best information available at any given point intime.

Recording Stalled Computations

Stalled computations are recorded in a data structure referred to as a“continuation.” A continuation has a status that can be, for example,“waiting-for-event” or “ready.” A stalled computation gets recorded as anewly created continuation with status “waiting-for-event.” Once thereason for stalling is satisfied (e.g., due to detection of the event),the status of the corresponding continuation is changed to “ready.” Eachcontinuation with status “ready” is stored in a “wait queue” of ascheduler object so that eventually it gets scheduled for execution. Incontrast, any continuation with status “waiting-for-event” will not bestored in any scheduler object's wait queue. Instead, it is stored inthe local shared memory of the physical node where the hardware eventthat stalled the corresponding computation is expected to occur, such asreceipt of a missing resource.

Additionally, the newly created continuation is associated with thestalling event that caused its creation. This mapping between (stalling)events and continuations awaiting these events permits fast dispatch ofasynchronous events (see the “handleEvent” described below). The mappingbetween continuations and events is stored in a table called “eventtable” and is kept in the shared memory of the corresponding physicalnode. Each physical node has its own event table, and an event table ofa physical node is directly addressable by every core on that physicalnode. All anticipated events recorded in an event table of a physicalnode correspond to hardware events that can occur on that physical node.The scheduler object s mapped to a physical node n represents n, and theevent table of n is associated with s. In some cases, severalcontinuations may be waiting on the same event, and so somedisambiguation may be required when the event is triggered.

Continuations are built using the “InitContinuation” routine. If adecision is made to move the computation, the remote physical nodeholding the resource will build a continuation that corresponds to thestalled computation and will store it in the remote physical node'sevent table. When that continuation resumes, the resource will beavailable. In effect, the hyper-kernel has transferred the virtualprocessor to a different node.

In the case where a decision is made to move the resource, the node thathas experienced the stall requests the transfer of the resource andbuilds a continuation using InitContinuation and stores it in the localevent table. Upon receipt of the resource, the continuation is attachedto an appropriate node in the TidalTree, and when that continuation isresumed, the resource will be generally be available and visible. Ineffect, the virtual resource has been transferred to the node thatrequested it.

Note that by placing continuations in event tables, it is guaranteedthat the processor that receives the event will quickly find the relatedcontinuations in its local event table. The reason for the stall in thecomputation will have been satisfied.

Having dealt with the stall, the virtual-processor p will in effect besuspended. In between processing the stall and finding a newcontinuation to resume, p becomes an “anonymous shadow processor,” i.e.,a processor with no identity known to the operating system. This shadowprocessor then looks for a new continuation to resume. An example ofthis is shown below in the “assignProcessor” routine described in moredetail below.

Notation

Let e be the event that stalled virtual processor p. Assume that e istriggered by local hardware of some physical node n. In particular,assume r is the resource, which caused the stalling event to occur.Resource r could be a block of memory, or an I/O operation, or a networkoperation. Assume that p is assigned to scheduler object s, whichbelongs to the subtree rooted at the scheduler object that representsphysical node n.

On-Stall

Pseudo code for an example on-stall routine is provided below in the“EXAMPLE ROUTINES” section. The migration-continuation function returnstrue if and only if processor p in node n decides that the resourceshould not move, i.e., the computation should move. This can bedetermined by a number of factors such as history and frequency ofmovement of r between nodes, the type of r, the cost of movement, thenumber of events in n's local event table waiting for r, system load,etc. For example, it may not be desirable to move a resource if there isa continuation stored in n's local event table that is waiting for it.

A variety of patterns of events that would benefit from migrationsexist. One approach to describing these patterns of events, like accessviolations, is in formal language theory. Regular (i.e., Chomsky type-3)languages can be recognized by finite state automata. In addition, usinga compact and flexible notation, a description of the events that areobserved can be made as sentences (or Chomsky sequences) in the regularlanguage, and the recognition modeled as state transitions in thecorresponding finite state automaton. When the full Chomsky sequence ofevents is seen, migration-continuation gets evaluated accordingly: ifthe finite state automaton accepts the Chomsky sequence, the conditionis met, otherwise, it is not met. The length of the minimized finitestate machine defines the amount of history that needs to be kept.

In various embodiments, all events happen locally, and the hyper-kernelon the physical node receiving the event must handle it—trulysynchronous events are not assumed to occur between physical nodes. Tocoordinate migration strategy between nodes, “messages” are used.Message “sends” are synchronous from a node's point of view, but message“receives” are asynchronous, in that a processor or shadow processor, ingeneral, does not wait for receipt of a message. When messages arrive,they are dealt with by the hyper-kernel as a virtual interrupt. In oneembodiment, the hyper-kernel will not allow a processor to resume acontinuation while there are messages waiting to be handled. Therefore,before control is transferred back to the operating system, the queue ischecked, and any messages are dealt with prior to the transfer ofcontrol back to the operating system.

For scheduler object s and continuation c, a cost function cost(s,c) canbe used to guide the search up the tree. If multiple ancestors of p havenon-empty queues, then p may not want to stop its search at the firstancestor found with a nonempty wait queue. Depending on the metrics usedin the optimizing strategy, p's choice may not only depend on thedistance between p and its chosen ancestor but on other parameters suchas length of the wait queues.

A function, find-best-within(s), can be used to return the “best-fit”continuation in a (non-empty) wait queue of a scheduler object. Examplesof parameters that can be considered include:

1. Position in the queue

2. The relationship between p and the last location recorded in thecontinuation (the closer those locations are the better it may be forreusing cache entries).

3. Performance indicators recorded in the continuations in the queue.

The cost and find-best-within functions can be customized as applicablewithin a given system.

Migrations Triggered by Asynchronous Events

Examples of asynchronous events include: receipt of a packet, completionof an I/O transfer, receipt of a resource, receipt of a messagerequesting a resource, etc. Generally, a hyper-kernel that receives anevent corresponding to a hardware device managed by the operating systemneeds to deliver a continuation associated with that event to ascheduler object s. By doing so, s will make this continuation availableto an appropriate scheduler object and then ultimately to thecomputation managed by the operating system represented by thatcontinuation. If, on the other hand, the event is the receipt of amessage from a hyper-kernel on another physical node, the hyper-kernelcan handle it directly.

To simplify explanation, in the examples described herein, an assumptionis made that there is only one continuation associated with an event.The procedures described herein can be generalized for the case wheremultiple continuations are associated with the same event, as needed.

In some embodiments, the search for a scheduler object on which to placethe continuation starts at the leaf of the tree that built thecontinuation and then proceeds upward (if the computation previouslyexecuted on this node). By doing so, the likelihood of reusing cacheentries is increased.

Handle-Event

Pseudo code for an example handle-event routine is provided below in the“EXAMPLE ROUTINES” section. The cost function, cost(s,c), is a functionthat helps determine the suitability of assigning c to scheduling objects. The cost function can depend on a variety of parameters such as thesize of the wait queues, the node traversal distance between s and theoriginal scheduling node for c (to increase the probability that cacheentries will be reused), and the history of the virtual processor, thephysical-processor, and the continuation. If the wait queues of thescheduler objects close to s already contain too many continuations,then it may take a relatively longer time until any newly addedcontinuation is scheduled for execution. Example conditions contributingto cost(s,c) are described below, and the conditions can be customizedas applicable.

Costs

Cost functions are used to evaluate options when selecting continuationsand scheduling objects. Cost functions can be expressed as the summationof a sum of weighted factors:cost=w ₁ f ₁ ^(x) ₁ +w ₂ f ₂ ^(x) ₂ + . . . +w _(n) f _(n) ^(x) _(n),

where w_(i) indicates the importance of the corresponding factor andx_(i) indicates an exponential.

Examples of factors f_(i) are listed for each of the costs below.Weights w_(i) and exponents x_(i) can be determined in a variety ofways, such as empirically and by simulation. Initial weights andexponents can be tuned to various application needs, and can be adjustedby an administrator to increase performance. The weights can be adjustedwhile the system is active, and changing weights does not change thesemantics of the hyper-kernel, only the operational performancecharacteristics.

Examples of the factors that can be considered include:

-   -   Length of time since the last processor evacuated this scheduler        object.    -   Height of the scheduler object in the TidalTree.    -   Length of the work queue.    -   Reservation status (i.e., it may be the case that some        application has reserved this resource for a specific reason).    -   Node specification (i.e., the node itself might have been taken        out of service, or is problematic, has in some way a specialized        function, etc.).    -   Age of the continuation in the queue.    -   Last physical processor to run this continuation.    -   Last virtual processor to run this continuation.    -   Node on which this continuation was last executing.    -   The “temperature” of the cache. (A cache is “warm” when it has        entries that are likely to be reused. A cache is “cold” when it        is unlikely to have reusable cache entries.)    -   Group membership of the continuation (i.e., the continuation may        be part of a computation group, each element of which has some        affinity for other members of the group).    -   Performance Indicators (Hints) and special requirements.

EXAMPLES

“OnStall” and “assignProcessor”

FIG. 8 illustrates an embodiment of a process for selectively migratingresources. In some embodiments, process 800 is performed by ahyper-kernel, such as in conjunction with the OnStall routine. Theprocess begins at 802 when an indication is received that a core (orhyperthread included in a core, depending on whether the processor chipsupports hyperthreads) is blocked. As one example, suppose a hyperthreadreceives a request, directly or indirectly, for a resource that thehyperthread is not able to access (e.g., RAM that is located on adifferent node than the node which holds the hyperthread). When thehyperthread fails to access the resource (i.e., an access violationoccurs), an interrupt occurs, which is intercepted, caught, or otherwisereceived by the hyper-kernel at 802. In particular, the hyper-kernelreceives an indication at 802 that the hyperthread is blocked (becauseit cannot access a resource that it has been instructed to provide). Inaddition to reporting its blocked state, the hyperthread providesinformation such as the memory address it was instructed to access andwhat type of access was attempted (e.g., read, write, or modify).

At 804, the hyper-kernel determines whether the needed memory should bemoved (e.g., to the node on which the blocked hyperthread is located),or whether the requesting process should be remapped (i.e., the virtualprocessor should be transferred to a different node). The decision canbe based on a variety of factors, such as where the needed memory islocated, the temperature of the cache, the workload on the node holdingthe hyperthread, and the workload on the node holding the needed memory(e.g., overworked or underworked). In some embodiments, the workload ofa node is determined based at least in part on the average queue lengthin the TidalTree.

If the hyper-kernel determines that the memory should be moved, thehyper-kernel uses its current resource map to determine which node islikely to hold the needed memory and sends a message to that node,requesting the resource. The hyper-kernel also creates a continuationand places it in its event table. The hyperthread that was blocked at802 is thus freed to take on other work, and can be assigned to anothervirtual processor using the assignProcessor routine.

The hyper-kernel checks its message queue on a high-priority basis. Whenthe hyper-kernel receives a message from the node it contacted (i.e.,the “first contacted node”), in some embodiments, one of two responseswill be received. The response might indicate that the first contactednode has the needed resource (and provide the resource). Alternatively,the message might indicate that the contacted node no longer has theresource (e.g., because the node provided the resource to a differentnode). In the latter situation, the first contacted node will providethe identity of the node to which it sent the resource (i.e., the“second node”), and the hyper-kernel can send a second messagerequesting the resource—this time to the second node. In variousembodiments, if the second node reports to the hyper-kernel that it toono longer has the resource (e.g., has provided it to a third node), thehyper-kernel may opt to send the continuation to the third node, ratherthan continuing to request the resource. Other thresholds can be used indetermining whether to send the continuation or continuing the resource(e.g., four attempts). Further, a variety of criteria can be used indetermining whether to request the resource or send the continuation(e.g., in accordance with a cost function).

In the event the hyper-kernel determines that the continuation should betransferred (i.e., that the computation should be sent to another noderather than receiving the resource locally), the hyper-kernel providesthe remote node (i.e., the one with the needed resource) withinformation that the remote node can use to build a continuation in itsown physical address space. If the remote node (i.e., the one receivingthe continuation) has all of the resources it needs (i.e., is inpossession of the resource that caused the initial access violation),the continuation need not be placed into the remote node's event table,but can instead be placed in its TidalTree. If the remote node needsadditional resources to handle the continuation, the receivedcontinuation is placed in the remote node's event table.

FIG. 9 illustrates an embodiment of a process for performinghierarchical dynamic scheduling. In some embodiments, process 900 isperformed by a hyper-kernel, such as in conjunction with theassignProcessor routine. The process begins at 902 when an indication isreceived that a hyperthread should be assigned. Process 900 can beinvoked in multiple ways. As one example, process 900 can be invokedwhen a hyperthread is available (i.e., has no current work to do). Thiscan occur, for example, when the hyper-kernel determines (e.g., at 804)that a continuation should be made. The previously blocked hyperthreadwill become available because it is no longer responsible for handlingthe computation on which it blocked (i.e., the hyperthread becomes an“anonymous shadow processor”). As a second example, process 900 can beinvoked when a message is received (e.g., by the hyper-kernel) that apreviously unavailable resource is now available. The hyper-kernel willneed to locate a hyperthread to resume the computation that needed theresource. Note that the hyperthread that was originally blocked by thelack of a resource need not be the one that resumes the computation oncethe resource is received.

At 904, the TidalTree is searched for continuations that are ready torun, and one is selected for the hyperthread to resume. In variousembodiments, the TidalTree is searched from the leaf-level, upward, anda cost function is used to determine which continuation to assign to thehyperthread. As one example, when a hyperthread becomes available, thecontinuation that has been queued for the longest amount of time couldbe assigned. If no continuations are waiting at the leaf level, or areoutside a threshold specified by a cost function, a search will beperformed up the TidalTree (e.g., the core level, then the socket level,and then the node level) for an appropriate continuation to assign tothe hyperthread. If no appropriate continuations are found for thehyperthread to resume at the node level, the hyper-kernel for that nodecontacts the root. One typical reason for no continuations to be foundat the node level is that there is not enough work for that node to befully utilized. In some embodiments, the node or a subset of the nodecan enter an energy conserving state.

Time Sequence

For expository purposes, in the example, a “swapping” operation is usedto transfer continuations and memory, but in fact that's not necessaryin all embodiments.

FIG. 10 illustrates an example of an initial memory assignment andprocessor assignment. Specifically, region 1002 of FIG. 10 depicts ahyper-kernel's mapping between physical blocks of memory (on the lefthand side) and the current owner of the memory (the center column). Theright column shows the previous owner of the memory. As this is theinitial memory assignment, the current and last owner columns hold thesame values. Region 1004 of FIG. 10 depicts a hyper-kernel's mappingbetween system virtual processors (on the left hand side) and thephysical nodes (center column)/core numbers (right column).

Suppose virtual processor P00 makes a memory request to read location8FFFF and that the hyper-kernel decides to move one or more memoryblocks containing 8FFFF to the same node as P00 (i.e., node 0). Block8FFFF is located on node 2. Accordingly, the blocks containing 8FFFF aretransferred to node 0, and another block is swapped out (if evacuationis required and the block is valid), as shown in FIG. 11.

Next, suppose virtual processor P06 makes a memory request to readlocation 81FFF. The contents of this block have been moved (as shown inFIG. 11) to node 0. The hyper-kernel may determine that, rather thanmoving the memory again, the computation should be moved. Accordingly,virtual processor P06 is moved to node 0, and may be swapped withvirtual processor P01, as shown in FIG. 12.

Performance Information

Locks and Other Synchronizers

In various embodiments, the use of synchronization mechanisms like locksis minimal. Locks are used, for example, to insert queue and removequeue continuations on scheduler objects and to maintain the eventtable.

Code Path Lengths

In some embodiments, the (maximum) length of all code paths isdetermined through a static code analysis, resulting in estimable andbounded amounts of time spent in the hyper-kernel itself. All datastructures can be pre-allocated, for example, as indexed arrays. Thenodes of the TidalTree are determined at boot time and are invariant, asare the number of steps in their traversal. One variable lengthcomputation has to do with the length of the work queues, but even thatcan be bounded, and a worst-case estimate computed. In otherembodiments, other variable length computations are used.

Static Storage

In various embodiments, all data structures needed in the hyper-kernelare static, and determined at boot time, so there is no need for dynamicmemory allocation or garbage collection.

Physical Memory

All memory used by the hyper-kernel is physical memory, so no pagetables or virtual memory is required for its internal operations(except, e.g., to manage the virtual resources it is managing), furtherhelping the hyper-kernel to co-exist with an operating system.

Sharing Data and Maintaining Consistency

In some cases, e.g., to preserve the conceptual integrity of the virtualmachine being presented to the operating system, changes in one node'sdata structures are coordinated with corresponding ones in a differentnode. Many of the data structures described herein are “node local,” andeither will not need to move, or are constant and replicated. The datastructures that are node local are visible to and addressable by allhyperthreads on the node. Examples of data structures that are not nodelocal (and thus require coordination) include the current resource map(or portions thereof), the root of the TidalTree, and migratorycontinuations (i.e., continuations that might have to logically movefrom one node to another).

A variety of techniques can be used to maintain a sufficient degree ofconsistency. Some are synchronous and assume all changes are visible atthe same time to all nodes (i.e., “immediate consistency”). Others allowa more relaxed solution and strive for “eventual consistency.” Asmentioned above, physical nodes of an enterprise supercomputer areconnected via one or more high speed interconnects. Multiple instancesof hyper-kernels are interconnected to pass messages and resources backand forth between physical nodes.

Updating the Current Resource Map

Each physical node n starts off (e.g., at boot time) with the same copyof the physical resource map, the initial virtual resource map, and thecurrent resource map. Each node maintains its own copy of the currentresource map.

In some embodiments, each entry for resource r in the current resourcemap has the following:

1. A local lock, so that multiple hyperthreads on a physical-node cannotmodify r at the same time.

2. A node number specifying the node that currently owns the resource.

3. A count k of the number of times n has requested r since the lasttime it owned r.

4. A boolean which when set signifies that this node n wants r.

5. A boolean which when set signifies that this node has r but is in theprocess of transferring it, in which case the node number specifies thenew owner.

In some embodiments, the count k is used to deal with unbounded chasingof resources. If k exceeds a threshold, a determination is made that itis better to move the newly built continuation rather than chasing theresource around the system.

The following is an example of a mechanism for initiating migration ofresources and receiving resources. Key transactions include thefollowing:

1. Node n sends a request for resource r to n′.

2. Node n′ receives a request for resource r from n.

3. Node n′ may send a “deny” message to n under certain circumstances,otherwise it can “accept” and will send the resource r.

4. Node n will receive a “deny” message from n′ if the resource r cannotbe sent by n′ at this point in time. It may be that r is needed by n′,or it may be that r is being transferred somewhere else at the arrivalof the request. If the request is denied, it can send a “forwarding”address of the node to which it's transferring the resource. It may bethat the forwarding address is n′ itself, which is the equivalent of“try again later.” When node n receives the deny message, it can resendthe request to the node suggested by n′, often the new owner of theresource. To avoid n chasing the resource around the system, it can keeptrack of the number of attempts to get the resource, and switchesstrategy if the number of attempts exceeds a threshold.

5. Node n will receive the resource r if n′ can send the resource. Inthis case, n needs to schedule the continuation c that was awaiting r,so that c can be resumed.

TidalTree Root

In some embodiments, one physical node of the set of nodes in the systemis designated as a “master node.” This node has the responsibility atboot time for building the initial virtual resource map and other datastructures, replicating them to the other nodes, and booting theoperating system (e.g., Linux). The master node can be just like anyother node after the system is booted up, with one exception. At leastone physical node needs to store the root of the TidalTree. The masternode is one example of a place where the root can be placed. Updates tothe event queue of the TidalTree root scheduling object are handled ineach node by sending a message to the master node to perform the update.

Over time, the hyper-kernel will adapt and locality will continuallyimprove if resource access patterns of the operating system and theapplication permit.

Continuations

As explained above, physical memory addresses across all nodes are notunique. In some embodiments, the inclusion of physical memory addressesin continuations can be avoided by using partitioned integer indices todesignate important data structures in the hyper-kernel. In the event anaddresses needs to be put into a continuation, care is taken in themove, since the address is a physical address of the source, and bearsno relationship with the physical address in the destination. Moving acontinuation means copying its contents to the destination node asdiscussed above, and remapping any physical addresses from the source tothe target.

Timestamps

In some embodiments, access to a free-running counter is visible to allof the nodes. In the absence of this, free-running counters on each nodecan also be used. Counters in continuations are mapped between thesource and destination.

Handling of Disks and Persistent Flash

Where a needed resource is on disk (or persistent flash), in someembodiments, such resources are treated as having a heaviergravitational field than a resource such as RAM. Accordingly, disk/flashresources will tend to not migrate very often. Instead, continuationswill more frequently migrate to the physical nodes containing therequired persistent storage, or to buffers associated with persistentstorage, on a demand basis.

Operating System Configuration

There are many ways to configure an operating system. For servers, anassumption can be made that its operating system is configured to onlyrequire a small set of resource types from the virtual machineimplemented by the hyper-kernel: storage that includes linear blockarrays, networks, processors, memory, and internode interconnects. As aresult, the complexity of the operating system installation can bereduced.

Example Data Structures and Functions

The following section provides a list of examples of data structures andfunctions used in various embodiments.

init-continuation: Initializes a continuation when a computation isstalled.

assignProcessor: Routine that assigns a new continuation to a shadowprocessor (if possible).

on-stall(r): Stalling event occurs for resource r.

migrate-computation(computational-state,r,n): Message to requestmigration of a computational state to another node n which you hope hasresource r.

on-interrupt(i): Software interrupt i occurs.

handle-event(e): Routine executed when the hyper-kernel is called on tohandle an asynchronous event.

request-resource(r,n): Request transfer of resource r from node n.

initiate-send-resource(r,n): Start sending resource r to node n.

on-request-transfer-response(r,n,b): The requested transfer of r from nwas accepted or rejected. b is true if rejected.

on-transfer-requested (r,m): Receive a request from m for resource r.

on-resource-transferred(r,n): Ack of resource r has been received fromn.

on-receive-resource (r,n): Resource r has been received from n.

migration-continuation(r): True if and only if it is better to migrate acontinuation than move a resource.

parent(s): Returns the parent scheduler-object of scheduler object s.

cost(s,c): Used to evaluate placement of continuation c in thewait-queue of scheduler-object s.

find-best-within(s): A cost function that returns a continuation storedin the wait-queue of scheduler-object s.

conserve-energy: Enter low power mode.

resume-continuation(c): Resume the computation represented by c in theprocessor executing this function at the point.

valid(i): Boolean function that returns true if and only if interrupt iis still valid.

initialize(best-guess): Initializes cost variable best-guess.

insert-queue(s,c): Insert continuation c into the wait-queue ofscheduler-object s.

return-from-virtual-interrupt: Resume execution that was temporarilypaused due to the interrupt.

r.owner: Returns the node where resource r is local.

r.e: Resource r is awaiting this event.

e.r: This event is for resource r.

e.continuation: When this event occurs, need to resume continuation.

get-state( ): Returns processor's state.

scheduler-object(p): Returns scheduler-object currently associated withprocessor p.

on-request-transfer-response(r,m, response): Response to request oftransferring resource r from node m. Response can be either true if“rejected” or false if “accepted.”

Example Routines

The following are pseudo-code examples of routines used in variousembodiments. In the following, functions that start with “on-” areasynchronous events or messages coming in.

========================== init-continuation(computational-state)========================== /* InitContinuation by processor p awaitingresource r with hints h */ c = allocate continuation c.state =computational-state c.last = scheduler-object(p) c.state =waiting-for-event c.hints = h e = allocate event in event-tablee.resource = r e.continuation = c return c end InitContinuation========================== assignProcessor ========================== /*Once processor p in physical node n becomes a shadow processor, it givesup its O/S identity and starts looking for a continuation with which toresume execution. p will look for such a continuation in wait-queues asfollows: */ s = scheduler-object (p) initialize (best-guess) best-s =nil /* traverse upwards, keeping track of best candidate */ /* assumethere is a locally cached copy of the root */ repeat guess = cost (s) ifguess > best-guess then best-guess = guess best-s = s s = parent (s)until s = nil if best-s <> nil then c = find-best-within (best-s)resume-continuation (c) else conserve-energy end assignProcessor========================== on-stall(r) ========================== /*OnStall is invoked when the hardware detects an inconsistency betweenthe virtual and physical configurations. More specifically, node nrequests resource r which the hardware cannot find on node n. */ ifmigration-continuation (r) then /* send the computation to node n */ nn= owner(r) /* node n believes resource is probably at node nn */migrate-computation (r,nn) else /* request the resource r */ c =init-continuation(get-state( )) /* insert code here to insert c into thelocal event-table */ request-resource(r, owner(r)) assignProcessor /* Atthis point, p is an anonymous shadow processor */ /* p needs to findsome work to do */ end OnStall ==========================on-migrate-computation(computational-state, r,n)========================== /* the remote node gets the message from n toreceive a continuation. Note: c in this case is the contents of thecontinuation, not the continuation itself. */ c = InitContinuation /*with the information in the request */ c.state = computational-state e =insert c into the local event-table handle-event (e) endon-migrate-computation ========================== on-interrupt(i)========================== /*When a processor p (in subtree of physicalnode n) is interrupted by i (using a very low level mechanism specificto the particular hardware design), p does the following: */ while valid(i) e = event-table (i) /* find the event corresponding to i */handle-event (e) i = next-queued-interrupt end while /* resume priorexecution */ return-from-virtual-interrupt end on-interrupt========================== handle-event(e) ========================== /*An event occurred. Move it from the event table to the bestscheduler-object. */ c = e.continuation /* find the continuation forevent e */ event-table (i). clear = true /* remove the event from thetable */ e.complete = true /* mark e as completed */ c.state = ready /*now find out the best place to put c */ s = c.last initialize(best-guess) /* look for best choice */ /* assume there is a locallycached copy of the root */ repeat guess = cost (s,c) if guess >best-guess then best-guess = guess best-s = s s = parent (s) until s =nil insert-queue (best-s,c)/* queue up c in the wait-queue of best-s */end handle-event ========================== request-resource (r,n)========================== /* When a node n needs a resource r owned bynode n′ the resource is requested, but the request may not be satisfiedbecause someone else might have beaten you to request it or n′ iscurrently using it. */ current-resource-map(r).wanted = truerequest-transfer(owner(r),r) /* send a request to the owner of r */ /*requesting r's transfer */ return ==========================on-request-transfer-response (r, m, is-rejected)========================== /* Now, consider that you are a node gettinga response from a previous request to a node for a resource r. When theresponse to this request comes in, it can be accepted or rejected. */ ifis-rejected then /* resource has been transferred to m */ increment k ifk > threshold then /* you don't want to go chasing around forever*/ /*trying to get the resource. Give up */ migrate-computation(r,m) returnelse request-transfer(r,m) /* try again */ return else /* request wasnot rejected and r is the resource */ r.k = 0 r.wanted = false /*resource has been moved */ r.owner = me /* set the owner to n (i.e.,“me”) */ if the resource is memory, update the hardware memory map withthe new memory return ========================== on-transfer-requested(r,n) ========================== /* When a resource request for r comesfrom node n, if transfer in progress to owner(r), deny the request */ ifr.being-transferred then send-request-response (r, owner(r), true) else/* transfer of resource is accepted */ r.transferring = trueinitiate-send-resource(r) if type(r) = memory then update local memorymap send-request-response (r, owner(r), false) return========================== on-resource-transferred (r,n)========================== /* When an acknowledgement comes in that thetransfer is complete */ r.owner = n r.transferring = false return========================== on-receive-resource(r,n)========================== /* Now we receive a message with therequested resource r from n*/ r.k = 0 r.wanted = false/* clear the bitsaying that it's wanted */ r.owner = me /* set the owner to n (i.e.,“me”) */ if the resource is memory, update the memory map with the newmemory send-resource-transferred(r,n) handle-event(r.e) /* the eventwe've been waiting for has occurred */ return

Network Attached Memory Using Selective Resource Migration

Described above are example embodiments of a hardware and softwarearchitecture in which a series of tightly coupled cluster of servers(also referred to herein as a “TidalPod”) share an aggregated set ofresources. These resources include several types, such as processors,dynamic memories, storage, and networks. The aggregation of theseresources by a hyper-kernel in such a system allows for the constructionof a virtual machine that spans the set of nodes and appears to anoperating system and to applications as a single large server.

Described herein are techniques for extending aggregation of resourcesby a hyper-kernel to include memory technologies such as flash memory,PCM (phase change memory), 3D-XPoint, hard disk drives, etc. Whileexample embodiments involving flash memory are described below, thetechniques described herein can variously be adapted to accommodate anytype of memory technology, as applicable.

In one example embodiment, flash memory is organized as a physical arrayof bytes. Each byte of this array corresponds to a physical memoryaddress in the virtual machine created by the set of hyper-kernelsrunning on each server (also referred to herein as “nodes”) of thecluster.

Typically, flash memory is used in two main ways: as solid-state disks(SSD) or as persistent memory in portable electronic devices such asmobile phones and tablets. One example primary usage for flash inservers is to simulate disks. Described herein are techniques thatprovide additional ways of using flash, for example, as a persistentbackup memory to (a) make large memories available for use byapplications and databases by extending the size of the memory asperceived by a guest operating system beyond that of the sum of theavailable dynamic memory of the cluster and (b) as a way to make systemsmore resilient in the presence of errors.

Unfortunately, most system software for servers typically have nomechanism to effectively deal with flash as a first class element of amemory hierarchy, and as a result, this software resorts to using it ina way that it understands well, namely disk storage.

Example Use Cases

The following are several example use cases supported by the techniquesdescribed herein:

1. Consider, for example, a software-defined server with 5 TB of mainmemory, and consider a flash memory array of 10 TB. In one exampleembodiment, the server is configured to have 10 TB of main memory, andto the 5 TB of main memory as a new cache of the 10 TB of flash memory.The use of such a cache accelerates the system.

2. In an alternative embodiment, the flash memory array may be used asif it were additional main memory for a total of 15 TB of main memory.

3. In another example embodiment, the flash memory can be used toimplement a persistent reference memory. For example, if a systemdetects an impending failure, the contents of the flash memory may beupdated with the most recent pages of main memory that it does notalready have. In this way, when the system restarts, the persistentmemory can be used to help restore the system to the previously savedstate (e.g., analogous to what is done when a laptop suspends/resumes).Thus, the main memory can be backed up to persistent storage so that thesystem can be restarted easily in the event of a crash, error, or otherfailure.

For example, typically, in the event of a failure (e.g., detection of apower failure or system crash), a snapshot of dynamic memory such asDRAM (dynamic random access memory), which is volatile (e.g., thecontents of the volatile memory are lost when power is removed), istaken and is written to disk. This can be avoided using the techniquesdescribed herein, as a reference copy can be stored or flushed to anetwork attached memory that includes persistent (e.g., static,non-volatile) memory such as flash memory. Details regarding anetwork-attached memory will be described in further detail below.

4. In another example embodiment, the techniques described herein may beused to save the state of a node and replace it with a different one.This may be done for various reasons, such as upgrading of a node,replacing a failing node, etc.

Memory Hierarchy

In the example architecture presented above, a large “physical” addressspace is presented to a guest operating system. From the point of viewof each node in the cluster, there are addresses in that “guestphysical” address space as seen by the operating system whose guestphysical addresses are directly addressed by the processors on thatnode. In some embodiments, if the guest physical address requested by aprocessor is not present on that node, a memory access fault isgenerated by the hardware, and either (a) the memory that contains thataddress is moved or copied to the node where the processor is located,or (b) the computation the guest processor was executing (i.e. thevirtual processor representing the guest processor) is moved to the nodewhere the guest physical memory is located. Examples of resourcemigration mechanisms and techniques using a hyper-kernel are describedabove. Either of these two strategies, once completed, enables thecomputation to be made available to be scheduled and, once scheduled,ultimately begins to run again, as if the memory access fault neverhappened.

In some embodiments, in this model, at any given time, the “guestphysical” memory is owned by at most one node in the system. Other nodesmay have copies of this memory, but, in some embodiments, in order tomaintain strong cache coherency, when a guest processor modifies thepage, either all the other copies must be marked as invalid, orotherwise forgotten.

In some embodiments, each page of dynamic memory in the system can be alocal copy of some other memory, i.e. an alternate flash memory or anetworked attached flash memory. This flash memory may be centrallylocated in a flash appliance accessible to all of the nodes in thecluster, or it may be distributed in parts throughout the cluster, onone or more nodes (e.g., on PCI cards including flash memory on one ormore nodes).

Such an array of flash memory is referred to herein, without loss ofgenerality, as a “network-attached memory.” The network-attached memory(also referred to herein as a “NAM”) may be composed itself of one morebanks of memory distributed amongst the nodes of the cluster. In variousembodiments, the network-attached memory can be implemented using memorytechnologies, such as PCM, 3D-XPoint, hard disk drives, etc., asdescribed above, with the techniques described herein variously adapted,as applicable. An example of a network-attached memory is described infurther detail below.

The network-attached memory can be used as an additional layer of memoryin a TidalPod. In one example embodiment, the network-attached memorycan be considered as the “real” home of all memory in the system (e.g.,TidalPod). When the network-attached memory is considered or used orconfigured in this manner, then parts of the network-attached memory maytemporarily reside on each node, for example, in the dynamic memory ofthe node. When considered in this way, the memory in each node can, insome embodiments, be used as a cache of the network-attached memory.

An example of a network-attached memory appliance is described infurther detail below in conjunction with FIG. 14.

In various embodiments, the normal memory hierarchy is thus extendedfrom only having cache levels on each node to having cache levels acrosstightly coupled nodes.

One example result of the techniques described herein in utilizing anetwork-attached memory is that the memory of the network-attachedstorage can greatly extend the available dynamic memory of the cluster,for example, due to an example requirement that the amount dynamicmemory of the cluster be in 1:1 correspondence with the virtual machinebeing presented to the operating system, not necessarily the sum of theall the physical primary memory on each node.

Strong Cache Coherency

In some embodiments, in order for the operating system and applicationsto properly function, the entire memory hierarchy must be strongly cachecoherent. In typical hardware, processors maintain strong cachecoherency synchronized using one or more levels of hardware caches. Whenmore than one processor exists on a node, using existing hardware, cachecoherency is maintained via an on-board interconnect such as AMD'sHypertransport™ or Intel's QuickPath Interconnect™.

However, those schemes do not extend beyond a single node (i.e., a nodehaving processors and memory). Described herein is a software version ofa strong coherency protocol that uses the mechanisms described above toachieve a similar effect.

In some embodiments, when a processor running under the direction of anoperating system writes to a location in its local memory, if a copy ofthat memory is stored in a hardware cache of a processor on that node,the processors must cooperate to maintain the strong consistency of thelocal caches.

Using the techniques described above (e.g., the hyper-kernel describedabove), a similar action can be taken. For example, when a guest virtualprocessor running under the direction of a guest operating system writesto a location in what it believes to be its local memory, if that memoryis in the dynamic memory of the node, care must be taken to make surethat any other node having a local copy of that memory invalidates it'slocal copy, so that one true copy is maintained in only one place in theguest virtual machine. When memory is extended to a network attachedmemory, the same write should have the same effect.

Migration to and from Network-Attached Memory

Described herein is an overview of how to maintain strong cachecoherency in the presence of networked attached memory. Additionaldetails are described below.

In some embodiments, when a computation on a node attempts to read froma location that is stored and owned on another node, the resourcemigration algorithms such as those described above are executed to makesure that the computation and the memory are co-resident on the samenode, either by moving the computation, or by moving the memory.

Techniques for extending resource migration to incorporate anetwork-attached memory flash appliance are described below.

In some embodiments, the set of nodes in a TidalPod that contain memoryis extended to include the flash appliance. The flash appliance istreated is another distinct resource type in the system. The flashappliance can be thought of as similar to the other nodes except that,in some embodiments, it does not have any virtual processors on whichcomputations can be scheduled. In some embodiments, the network-attachedmemory appliance does not start off with any virtual processors, andnever accepts any virtual processors from other nodes in the TidalPod.

FIG. 13A illustrates an example embodiment of a system in which anetwork attached memory is used in selective resource migration. In theexample shown, nodes 1304 (examples of nodes 458-462) of TidalPod 1302communicate with a persistent memory array 1306 (example of anetwork-attached memory). In some embodiments, the nodes and NAMtogether form the TidalPod (where the NAM is a specialized node in theTidalPod). In some embodiments, the nodes and the NAM of the TidalPodcommunicate with each other over an interconnect (1308).

In one example embodiment, each of nodes 1304 includes a motherboard(1310), where the motherboard may have a number of processors, whereeach processor may have a number of cores, and each core may have anumber of hyperthreads, as described above. In some embodiments, theguest operating system running on the TidalPod views each hyperthread asa processor.

In some embodiments, the network-attached memory 1306 is an array ofmemory (1312) (e.g., bytes of flash memory). The NAM also includes aprocessor (1314) configured to implement a cache coherency protocol, asdescribed herein. Multiple NAMs may be used for redundancy and/orresiliency. In this example, the network-attached memory appliance 1306is centrally located in a flash appliance accessible to all of the nodesin the cluster. In other embodiments, the network attached memory may bedistributed in parts throughout the cluster, on one or more nodes (whereexamples of portions of the NAM distributed across nodes 1304 are shownat 1316-1322).

Using the techniques described herein, pages of memory may be placed inthe NAM, just as pages of memory can be put on any node in the system,as described above (e.g., when performing memory migration). In someembodiments, the network-attached memory appliance communicates with theother nodes in the TidalPod over the interconnect using a cachecoherency protocol, which will be described in further detail below.

FIG. 13B illustrates an example embodiment of a system in which anetwork-attached memory is used in selective resource migration. In thisexample, nodes 1352 and 1354 are examples of nodes 1304 and 458-462. Asshown in this example, each node has a hyper-kernel. Also shown, is anexample embodiment of a memory or cache hierarchy on each node, whichinclude L1, L2, and L3 caches. Each node also includes DRAM, used as anL4 cache.

As shown in this example, nodes 1352 and 1354 communicate with eachother (e.g., over an interconnect), for example, migrating resourcesbetween each other. In this example, the nodes are also configured tocommunicate with persistent memory array 1356, which is an example of anetwork-attached memory. The NAM and the nodes of the TidalPodcommunicate using a cache coherency protocol, described in furtherdetail herein.

FIG. 14 illustrates an example embodiment of a network-attached memoryappliance. One example implementation of a NAM is as follows. The NAM(1402) includes a number of flash memory chips (e.g., memory chip 1404)arranged in a 2D (two-dimensional) array on a board. In this example,the memory chips are arranged in banks and rows. The memory chips areconnected on a memory bus (1406). The memory bus allows a processor(1408) to put out addresses to a memory controller 1410 (e.g., addressspecifying bank X, chip Y, page Z), which is then configured to returnthe appropriate page from the specified combination of bank/chip. Forexample, the memory controller takes the total number of chips, dividesthat by the number of pages on a chip, divided by the number of rows,etc. to return the appropriate page.

In this example, the processor included in the NAM is a coordinator,implemented, for example, as a special limited processor, a networkprocessor, or a protocol processor that is configured or programmed tocommunicate with other nodes in the TidalPod, for example, receivingmessages and providing responses as part of a cache coherency protocol,which will be described in further detail below. In some embodiments,the messages include acknowledgments, retries, etc. that arecommunicated between nodes of a TidalPod. One example of a message is amessage to migrate a vcpu on node n to a node m. Example pseudocode forsuch a message is provided below:

Migrate this VCPU “V” to Node M

-   -   Snapshot the state of V (typically a small number of pages of        memory (e.g., ˜6400 bytes))    -   Send “migrate” command with the appropriate number of bytes to        contain the state V to M (e.g., 6400 bytes)    -   Wait for acknowledgment

Additional examples of messages and an example message structure will bedescribed in further detail below. In some embodiments, the processorincluded in the NAM is invisible to the guest operating system.

In this example, the NAM also includes metadata 1412. In someembodiments, the metadata includes page state data used to keep track ofwhich pages are in what state. In some embodiments, the page state dataindicates the type of the page (e.g., secondary). In some embodiments,the NAM includes metadata that indicates the state of the page onvarious nodes throughout the TidalPod. For example, the state of thecopy of the page on the NAM is typically a secondary. Copies of the pageon other nodes may be secondary, prime, or exclusive. This informationcan be used, for example, when performing a recovery in a fail overscenario, to restore the state of the TidalPod (e.g., to indicate that acopy of the page on a first node in the TidalPod should be marked asprimary (also referred to herein as “prime”), while another copy of thepage on a second node should be marked as secondary).

In some embodiments, all pages of the NAM are initially invalid (e.g.,on startup of a TidalPod). When a page is written into on a node, a copyof the page is sent to the NAM according to a page/cache coherencyprotocol described in further detail below. Thus, over time, as pagesare created and written on the TidalPod, the NAM maintains a recent copyof all those pages that are created and written (e.g., a copy of thedynamic memory).

In some embodiments, when a large memory system is started up (e.g.,large memory Linux or FreeBSD system), typically a zeroing of the pagesis performed. This process may take a long amount of time for largememory systems. In some embodiments, using the techniques describedherein, the zeroing of pages can be performed more quickly and moreefficiently. For example, the zeroing can be performed in parallel, andin a “lazy” fashion. In some embodiments, pages in the system that havenot yet been zeroed are indicated as “dormant” pages. In someembodiments, these dormant pages are not zeroed until the first timethat they are used (e.g., allocated and written into or created). ATidalPod system can boot up quickly by using this “parallel lazyzeroing” technique.

In some embodiments when the TidalPod system starts off, there are noentries in a second level page table (described in further detail below)for dormant pages, as they have not yet been created, and therefore donot yet exist (i.e., dormant pages do not have any physicalrepresentation until they are allocated). In some embodiments, when adormant page is allocated, it is zeroed. An entry is then placed in thesecond level page table, which makes the page valid and non-dormant.

FIG. 15 is a diagram illustrating an embodiment of allocating a page.The diagram variably applies to dynamic memory and a network attachedmemory. In the example shown are dormant pages (1502 and 1504). When adormant page is allocated, it is zeroed out (e.g., as shown at 1506). Anentry is then placed in a second level page table, as described above.When the entry is made, the physical address of the page is entered. Insome embodiments, mode bits are also entered for the page. The mode bitscan indicate that the page is valid, whether the page is writable orread-only, etc.

In some embodiments, when a system such as a TidalPod starts up, allpages are empty (e.g., dormant). The guest operating system then beginsallocating pages. For example, when a page is allocated, a page number(e.g., 4567) is allocated. Upon allocation, the page is zeroed out, andthen its address is put in the second level page table (the page is notmade visible until after it has been zeroed out). Now, if an attempt ismade to address some pages that are known to the hyper-kernel as 4567, apage of zeroes will be seen.

In some embodiments, until allocation, the page does not exist. When aTidalPod with a number of nodes and processors is started up, a majorityof the pages are dormant at startup time. As the pages are used, theybecome valid. This holds true for pages in dynamic memory as well as inthe NAM.

In some embodiments, the number of pages in the NAM agrees with thenumber of pages that the guest operating system observes. Other copiesof pages (e.g., shadow copies) of the page may exist (e.g., in a pagecache), but, in some embodiments, they are not made visible to the guestoperating system. There need not be a one-to-one correspondence betweenthe hyper-kernel(s) and the NAM. However, in some embodiments, there isa one-to-one correspondence as seen by the guest operating system.

In a typical operating system, an operating system runs on a bare metalmachine. As described above, using the techniques described herein, thebare metal machine is replaced with a distributed hyper-kernel, whichgives the operating system the impression that it is running on a baremetal piece of hardware. This is supported by second level page tables,which exist in processors on the nodes in the TidalPod. If there is notan entry in the second level page table for a page of memory, a faultwill occur when performing hardware address translation. As describedabove, based, for example, on cost functions, the virtual processor canbe moved to the page with the memory, or the memory can be moved towhere the virtual processor resides. In some embodiments, when thememory is moved, not only are the contents of the memory copied over,but the second level page table at the destination (node) is alsoupdated. Thus, when a process on the node attempts to access the page,another fault will not occur. This provides, to the guest operatingsystem, the appearance of a single large address space, which does notexist in hardware, but is defined and supported in software using thetechniques described herein. If the request for a page is rejected(e.g., based on a message that comes into the cost function), then theprocessor moves to the location of the page (or both the virtual processand the page are moved to another node—i.e., post-condition, they areco-resident).

In some embodiments, when a page is requested, the page is requestedfrom its primary location. That page is then marked as secondary, whilethe page sent to the requesting node is marked as exclusive or prime onthe requesting node.

Consider the following example. Suppose that a TidalPod includes, forillustrative purposes, a centralized network-attached memory, and twonodes, node1 and node2. In some embodiments, when a strategic decisionis made to have node1 request the transfer of memory (i.e., page ofmemory) whose latest copy is on node2, node2 first sends an invalidationof that memory to the network-attached memory, along with an indicationthat node1 is most likely the place or location that the latest copy canbe found, and then satisfies node1's request by sending a copy of thatmemory to node1. In some embodiments, the memory now on node1 is updatedas dictated by the various computations resident on node1, and then whennode1 must transfer that memory somewhere else, node 1 may also updatethe network-attached memory to where the current version of that memorymay be found. In some embodiments, the system (TidalPod) continues towork or function whether or not the update is made to the NAM, sinceknowledge of the system may not be perfect. In some cases, due toasynchronicity, memory pages may need to be “chased down” and searchedfor, because they may not be in a location where they were expected tobe (e.g., according to a resource map). For example, at one point intime, the page may have been at a given location, but may no longer bethere when the search for the page is made.

If another node needs a copy of that memory (page), a copy is sent tothe requesting node, and a copy of that memory is also sent to thenetworked attached memory.

In some embodiments, when memory is modified on a node, the memorybecomes exclusive to that node. In some embodiments, all other copiesmust become invalid, including any copy on the networked attachedmemory.

In some embodiments, on a periodic basis, the network-attached memorymay request a secondary copy of every memory page. On planned orunplanned shutdown, if there is sufficient time, the network-attachedmemory may request exclusive ownership of all pages, after guest virtualprocessors are stopped.

In this way, the network-attached memory always contains a sufficientlyrecent copy to preserve the semantics of strong coherency.

Description of State Transitions and Cache Coherency Protocol

As described above, the network-attached memory (“NAM”) may be anothernode in a TidalScale Pod (centralized node or distributed across othernodes in the pod), with the exception that no virtual processors (alsoreferred to herein as “vcpu's”) can be started on it, and to which novcpu's can ever migrate.

In this example, the NAM is transactional in nature, given that novcpu's are present on the NAM. There is no requirement or need to keepthe contents of the NAM up to date in real time, except, in someembodiments, for well-defined synchronization points defined by theexecution of the guest software (e.g. “I need this page in order toprogress the computation and until I get it I cannot progress thecomputation”). Thus, reads and writes to the NAM can be performed in a“lazy” manner. As long as requests for pages and requests to updatepages are satisfied, in order, consistent von Neumann semantics can bemaintained or preserved, without having to perform then in real-time. Itmay also be the case that some processor families have additionalconstraints that must be satisfied, for example, Intel's “memory storageorder” constraints.

In some embodiments, the logic to request a page, update a page, migratea processor, invalidate read-only copies of pages, etc. is handled byvcpu's or housekeeping threads. Because the NAM does not have those, theNAM does not have to worry about these operations.

An example embodiment of a transactional structure is now described.

Pages on any node can be valid, or invalid. The validity/invalidity of apage refers to whether an entry to that page exists in some page tableon a node. If they are valid, they correspond to an address that theguest operating system perceives to be a physical address, but is inreality a guest virtual address when viewed by the hyper-kernel.

A valid page p resident on a node n may be in one of several states:Prime (or primary), or Exclusive or Secondary.

1. If p is marked Prime, it is “read-only” and n is said to “own” p.

2. Nodes other than n may have copies of p, which are marked or calledSecondaries. In some embodiments, if there is a secondary, it can bevalidly assumed that there is a prime somewhere else in the TidalPod.Similarly, if a node has a prime page, then it can be assumed that theresecondaries of the page elsewhere in the TidalPod. In some embodiments,the number of secondaries is maximized so that when attempts to readthose pages are made, the page data is already resident on therequesting node, minimizing time spent accessing the page data.

One example of where a secondary may be desired is when handling a setof pages that hold the code of an operating system (e.g., guestoperating system). Because the code for the operating system is constantand does not change, it would be inefficient if the processors runningthe operating system were to fetch pages for the operating system (asthis may result in a stall while the processor is waiting for therequested page). Instead, to improve efficiency and reduce stalls,secondaries can be used, where as many pages of the operating system arereplicated as possible. By reducing stalls, overhead in the system isalso reduced, leading to increased efficiency of the system.

Similar optimizations and efficiencies can be performed for other kindsof programs, such as those with read-only data (where pages of theread-only data are copied as secondaries to read only nodes). In someembodiments, no distinction is made between code pages of an operatingsystem or an application that are read-only pages of memory.

As another example, secondaries can be used that have large amounts ofdata that do not change very often. If the memory is available to do so,as much of the read-only data can be replicated as possible to improveefficiency and reduce stalls.

3. If p is marked Exclusive on n, the page can only exist on n, therecan be no other copies, and the page can be read and written into(“read-write”). In this case, there are no secondaries for p.

In some embodiments, before a page is made exclusive, an invalidationoperation is performed to invalidate all other existing copies of thepage. This can be used to guarantee evaluation order in existingarchitectures. The invalidation operation can be performed by sendingout messages to all other nodes, requesting that they invalidate theircopy of the page. When responses (e.g., acknowledgments) to thoserequests are received, the receipt of all those responses indicates thatthere are no other locations at which the page exists. The guestoperating system can then start up again and write to the page. When thewrite is completed, other pages may want to have a copy of the page, andin some embodiments, a snapshot of the page can be taken and used tocreate new secondaries that have the updated information for the page.Thus, through the use of secondaries, it will appear to the guestoperating system that the pages are local.

When a vcpu on a node m (m≠n) requests access to p from n, if that pageis Prime or Exclusive, the page p currently on n is marked Invalid, anda copy of the page is then sent to m which marks p as Prime. In someembodiments, as an optimization, the vcpu on node m may mark the page pas Exclusive if the vcpu on node m knows that is what is needed.

In some embodiments, if a node has a page that is prime or exclusive,then when it receives a request to send prime or exclusive writes tothat page it is converted on that node to a secondary. The right towrite into that page is then transferred to the node that is requestingthe page. This is an optimization that may be performed based on anassumption that the node would not be requesting the page unless thenode were going to write to the page. This saves a transaction in theprotocol having to be performed, increasing efficiency.

In some embodiments, if node m requests access to p from n, then node nmarks its copy of p as secondary. The page p is then sent to node m. Ifnode m marks its copy of p as exclusive or prime, then node n's copy ofpage p is invalidated.

In some embodiments, if a page p on node n is Prime, and is to bewritten into, all secondary copies must be made invalid, and only afterreceiving an acknowledgement that this has been accomplished, n marks pas Exclusive. For example, in some embodiments, the page cannot bewritten into until it is known that node n is the sole writer—that is,the page cannot be written into until the page is in the exclusivestate, where the page cannot be in the exclusive state until allacknowledgments have been received indicating that there are no othersecondaries (i.e., all secondaries have been invalidated). In someexample implementations, this can be optimized. For example, the nodethat is primary for this page can initiate the invalidations. In someembodiments, the invalidations include instructions that theacknowledgements should be sent to the requestor (who is about to becomeprimary) NOT to the current primary. In some embodiments, the requestermust collect all the acknowledgements before the page can be accessed.In this way, the invalidations can proceed safely in parallel with thetransfer of the page. In summary, in this example optimization, theprimary initiates the invalidations, but the requestor completes theinvalidation process.

The following are additional details regarding invalidations. In someembodiments, the TidalPod includes first level page tables, whichperform hardware translation from the user space (e.g., guest programrun in user space) to what the guest operating system believes is itsphysical space (i.e., the first level page table mapping translatesvirtual addresses into what the guest OS believes to be physicaladdresses). As described above, what the guest OS believes to bephysical addresses are guest physical addresses managed by thehyper-kernel (e.g., hyper-kernel host addresses), which then go throughanother level of page address translation, in hardware (e.g., via asecond level page table), where the guest physical addresses areconverted or translated into true physical addresses of the pages. Insome embodiments, a page is invalidated by erasing it from the secondlevel page table. Garbage collection can then be run, or memory can bereturned to a free pool, etc., as the nodes can no longer access theinvalidated page of memory.

After this, all write operations to a page marked Exclusive will notgenerate any stalls, since they can be locally read and written into onthe node, and no other copies exist (e.g., pages invalidated by erasingthem from the second level page table, as described above).

In some embodiments, the NAM abides by the same protocol describedabove. As with any other node in the TidalPod, the NAM also has validand invalid pages. For example:

1. All pages in the NAM start off as invalid. In some embodiments, if apage becomes valid, it is marked as secondary, because the page on theNAM cannot be written into (only read from).

2. Before a vcpu v on a node n writes to a page it must invalidate allcopies of P elsewhere, including the NAM. Therefore, if the NAM has asecondary for p, p must be made invalid on the NAM, and send anacknowledgement that it has been made invalid before p can be updated,just as any other node that has a copy of p must do.

3. If a node n responds to a read request coming from a node m, m n, fora page p, where p is marked Primary or Exclusive, n marks p assecondary, and sends the page p to m, and also at (roughly) the sametime, n also sends it to the NAM, which marks it as valid and secondary.Thus, in some embodiments, if a node marks a page as exclusive orprimary, a copy of the page is sent to the network attached memory (andmarked as secondary) so that the network attached memory has a validcopy of that page (i.e., if a node has a prime copy of the page (e.g.,after writing to the page), the NAM will have a secondary copy that isvalid after the write). After the page is received by m, m marks thepage as Primary. As before, if the page transitions from Primary toExclusive as would be the case for a remote write request, the Secondarycopy on the NAM must be made invalid. If it is known ahead of time thatthe page will be marked Exclusive, the step of sending the page to theNAM can be skipped (as it would ultimately be invalidated anyway).

In this way, the NAM becomes a collection over time, of copies of allvalid pages in the TidalPod. In some embodiments, each time a page isupdated, an update is made to the network attached memory. Thus, overtime, after a period of quiescence, the network attached memory willhave a valid copy of every page in the TidalPod. Thus, even if power tothe system goes out, an image of the memory will reside in the NAM. Asanother example, when booting, if a clean shutdown was not performed,then snapshot of the memory may be used to help restore the previousstate of the system prior to the shutdown.

Finally, there is no restriction on the number of NAM's in the TidalPod.For example, there may be multiple NAMs in the system (e.g., forresiliency and/or redundancy). In some embodiments, several networkattached memories can be shared between different TidalPods. As oneexample, a NAM appliance can be unplugged and replicated for thepurposes of resiliency and/or redundancy.

For example, when data is pulled off of storage (e.g., extracted fromfiles), it may be transformed into a local representation usable by anapplication or database that will operate on the data. In one exampleuse case, once the data has been transformed and is replicated to a NAM,the NAM can be unplugged and moved to another TidalPod. Thus, thetransformed data can be immediately used by the other TidalPod, savingthe expensive cost of transforming the raw data first. For example, theinitial load of data (e.g., from a database, streamed over the internet,read from a disk, etc.) that must then be transformed to be usable by anapplication running on a TidalPod that needs the data can be expensive,especially for very large files. This initial load/transformation can beskipped using the steps described above (e.g., needs only to beperformed once, where the transformed data can be replicated or moved toother systems by moving the NAM).

Example State Transitions

The following is a table of example state transitions:

TABLE 1 Old page Operation state Action New Page state local readinvalid request page from primary or primary exclusive local readsecondary perform the read secondary local read primary perform the readprimary local read exclusive perform the read exclusive local writeinvalid request write from primary exclusive local write secondaryrequest write from primary; exclusive invalidate local write primaryinvalidate; write exclusive local write exclusive perform the writeexclusive receive read invalid forward to primary invalid receive readsecondary forward to primary secondary receive read primary send thepage secondary receive read exclusive send the page invalid receivewrite invalid forward to primary invalid receive write secondary forwardto primary invalid receive write primary send the page invalid receivewrite exclusive send the page invalid invalidate invalid Ack invalidinvalidate secondary invalidate; ack invalid invalidate primary N/Ainvalid invalidate exclusive N/A invalid

In the above example of Table 1, when a read request for an exclusivepage is received, the page is sent to the requestor and the stage of thepage (on the node that receives the read request) is transitioned toinvalidate. In some embodiments, the transition to invalid takes intoaccount an optimization, as described above, in which an assumption ismade that the page that has been requested will be written into, and thepage on the node that received the request will ultimately need to beinvalidated anyway. In other embodiments, in response to a receiving aread request, the node that receives the read request transitions thestate of the page from exclusive to secondary.

In some embodiments, all nodes of a TidalPod, including the NAM, abideby the above example state transition diagram for the cache coherencyprotocol described herein. In the case of the NAM, which does notperform computations (e.g., writes on the pages that it holds), the NAMabides by the subset of transitions associated with passive operations.

Example Messages

The following are example of messages used in the internode cachecoherency protocol described above:

In some embodiments, each subsystem has its own message types. Thefollowing are examples of subsystems in a TidalPod (e.g., schedulersubsystem, I/O subsystem, migration subsystem, etc.):

-   -   TS_NET_SCHEDULER,    -   TS_NET_MEMORY,    -   TS_NET_IO,    -   TS_NET_MIGRATION,    -   TS_NET_REMOTE,    -   TS_NET_REMOTE_INIT,    -   TS_NET_IOAPIC,    -   TS_NET_CONTROL,    -   TS_NET_BENCHMARK,    -   TS_PAGE_BENCHMARK,    -   TS_SYNC_CLOCK,    -   TS_NET_MMIO,

In some embodiments, the TS_NET_MEMORY subsystem has the followingexample message types:

-   -   VMEM_UNKNOWN=0,    -   VMEM_BUILD_GCPP=1, //message to node to build its cpp (coherency        page protocol).    -   VMEM_BUILD_COMPLETE=2, //message that the build is complete    -   VMEM_MOVE_OWNER=3, //message carrying page from owner to owner    -   VMEM_COMPLETE_PAGE=4, //message used to signal page state change        complete    -   VMEM_OK2SEND=5, //message used to broadcast available room for        pages    -   VMEM_COLLECT_PAGE_BCST=6, //message used in isolating protocol        (path where the collect message is broadcast).    -   GTHREAD_COLLECT_BCST=7, //message used to collect guest thread        metadata    -   GTHREAD_COLLECT_BCST_ACK=8, //message used to respond to a guest        thread collect message

Example Scenario

FIG. 16 illustrates an example embodiment of internode communicationaccording to a cache coherency protocol such as that described above(e.g., according to the state transitions in Table 1, above).

In this example, suppose that a TidalPod includes nodes N₀ (1602), N₁(1604), and N₂ (1606), as well as NAM 1608.

In an initial state 1610, node N₂ has the primary version of page p(indicated with a “P”). Node N₁ includes a secondary copy of page p(indicated with an “S”). Node N₀ does not have a copy of page p (e.g.,invalid, as indicated by “X”). NAM 1608 may include either a secondarycopy of page p (e.g., the system has been in use and the NAM has areference copy of page p), or the page may be invalid on the NAM (e.g.,at startup).

In a next step 1612, node N₀ wishes to perform a local read of page p.Because it does not have a valid copy of page p, it performs a remoteread request for the page from the node that has the primary copy ofpage p, in this case, node N₂ (e.g., based on resource maps).

In response to the remote read request, node N₂ marks its copy of page pas secondary (transition from primary to secondary), and sends the pagep to node N₀. Node N₂ also sends page p to the NAM, which marks itsreceived copy (e.g, snapshot) of page p as valid and secondary. Afternode N₀ receives page p, node N₀ marks its copy of page p as primary.

In some embodiments, node N₀ receives a copy of page p that is marked assecondary. In other embodiments, and as shown in this example, in orderto minimize the number of transactions (e.g., messages that are beingcommunicated among nodes), node N₀ marks its copy of p directly asprime, under the assumption that node N₀ is requesting the page with theintention of writing into it. The page p on node N₂ is then marked assecondary. If the page p was invalid on the NAM, the page p is also sentto the NAM, where it is marked as a secondary. If the page exists on theNAM, it remains secondary. The copy of page p on node N₁ remainssecondary.

In a next step 1614, node N₀ performs a local write into its primarycopy of page p. Before node N₀ can write into or update its copy of pagep, all secondary copies of page p are made invalid. For example,invalidation messages are sent to N₁, N₂, and the NAM (i.e., other nodesin the TidalPod that have secondaries of p are requested to invalidatetheir copies of page p). After node N₀ receives acknowledgments from N₁,N₂, and the NAM indicating that they have invalidated their copies of p(i.e., no other copies of p exist in the TidalPod), where theinvalidation on those nodes is indicated by the symbol “X”), node N₀ canthen mark its copy of page p as exclusive (e.g., transition from primaryto exclusive) and write into its copy of page p.

In the above example, node N₀ first performed a remote read request at1612 and then subsequently performed a local write at 1614. If it isknown ahead of time that the page on node N₀ was to be marked exclusive(e.g., similar to a remote write request), the step of sending the pagep to the NAM from node N₂ in 1612 may be skipped.

Now suppose at 1616 that N₁ attempts to perform a local read of page p.However, its copy of page p is invalid. Node N₁ then requests the page pfrom node N₀. In response to the remote read request, node N₀transitions its copy of page p to secondary (or in some embodimentsinvalidates its exclusive copy of page p if the requestor is expected towrite into p), and sends page p to node N₁. Node N₁ marks its receivedcopy of page p as primary. Node N₀ also sends a copy of page p to theNAM, which marks its copy of page p as valid and secondary.

As shown in the example above, a page may be in different states ondifferent nodes of a TidalPod. In some embodiments, a parallel datastructure is used to maintain the metadata about the state of pages onvarious nodes in the TidalPod. In some embodiments, the structure ismaintained such that re-computation of the state of pages across nodesin the TidalPod need not be performed.

In this example embodiment, the NAM is passive, and is not configured torequest pages and write into them. The NAM, over time, builds up a setof secondary pages. If a node attempts to write into a page, the copy onthe NAM becomes invalid.

In some embodiments, the NAM is notified, using the cache coherencyprotocol, of any transition from primary or exclusive to secondary(i.e., the NAM is copied on those transitions). Thus, the NAM is updatedany time a page transitions from being exclusive or prime to secondary.If a page p on a node N becomes secondary, then the page on the NAM mustalso be updated to become a secondary. Thus, the NAM preserves the stateof a set of pages that it believes are valid, and, in some embodiments,the NAM has the “ultimate” reference copy (or an approximation) of theofficial memory of the TidalPod.

In some embodiments, if it is detected that the TidalPod is failing orcoming down, then the NAM makes read requests for copies of all primarypages in the TidalPod, which the NAM does not already have, which willbe marked as secondary on the NAM. Given sufficient time, this willresult in the NAM having all secondary copies of the pages on the nodesin the TidalPod (and becoming, for example, an “ultimate referencecopy”). As one example, suppose that a failure or error is detected. TheNAM searches through all of its pages to determine which pages areinvalid. The NAM attempts to make them valid by making a read requestfor copies of those pages from other nodes in the TidalPod. If copiesare obtained from other nodes, then the NAM updates its invalid pagewith the obtained copy of the page, which is then made valid andsecondary on the NAM.

In some embodiments, the NAM includes backup systems, such as batterieson the motherboard that allow the NAM to continue to function, forexample, during a system shutdown or loss of power. This provides theNAM with time to request secondary copies of pages on other nodes in theTidalPod (to transition from an invalid page to a valid secondary). Thisallows the NAM to complete itself in a failure situation.

FIG. 17 is a flow diagram illustrating an embodiment of a process formaintaining cache coherency in the presence of a network attachedmemory. In some embodiments, process 1700 is executed by a networkattached memory such as network attached memory appliance 1306. In someembodiments, process 1700 is performed according to a cache coherencyprotocol such as that described above. The process begins at 1702, whena message is received at a network attached memory. The message isreceived based on an operation to be performed with respect to a page ona node (e.g., a TidalPod). In some embodiments, the node is included ina plurality of nodes with which the network attached memorycommunicates. In some embodiments, a virtual machine is created by a setof hyper-kernels running on each node in the TidalPod. An operatingsystem may then be collectively run on the plurality of physical nodes.In some embodiments, the (guest) operating system is transparently run.For example, as described above, by using hyper-kernels, the operatingsystem is given the impression that it is running on a bare metal pieceof hardware (while being collectively run on a plurality of physicalnodes as in a TidalPod), where modifications to the operating systemneed not be made.

As described above, in some embodiments, the network attached memory isorganized as a physical array of bytes. In some embodiments, each byteof the array corresponds to a physical memory address in the virtualmachine.

In some embodiments, the network attached memory is a centralizedappliance. In other embodiments, the network attached memory isdistributed across the nodes in the TidalPod. At 1704, an action isperformed by the network attached memory based on the received message.

As described above, in various embodiments, operations that can beperformed with respect to pages of memory on nodes include reads andwrites (which may be local or remote). Based on the type of operation tobe performed, different types of messages can be sent out.

For example, if the operation is a request to write into the page,invalidation requests (examples of messages at 1702) are sent to andreceived by other nodes as well as the network attached memory toinvalidate their copies of the page to be written into. The networkattached memory is configured to then invalidate its copy of the page.The network attached memory is also configured to return anacknowledgment indicating that its copy of the page is now invalid. Thewrite operation can then proceed after receiving acknowledgments to theinvalidation requests.

If the operation is, for example, a remote request from a node to read apage, the page (e.g., copy or snapshot of the page, where the message at1702 includes the copy of the page) is sent to the requesting node aswell as the network attached memory. The network attached memory is thenupdated with the copy of the page (e.g., the network attached memorystores the copy of the page at 1704).

Other examples of operations, actions, and page state transitions aredescribed above in conjunction with Table 1.

FIG. 18 is a flow diagram illustrating an embodiment of a process forzeroing pages. In various embodiments, process 1800 is performed by anode and/or a network attached memory included in a TidalPod. Theprocess begins at 1802 when an indication to allocate a dormant page isreceived. In some embodiments, a dormant page is a page of memory thathas not yet been zeroed. In various embodiments, the page of memoryincludes a page in DRAM (e.g., on a node in a TidalPod), a page in aflash memory (e.g., non-volatile memory in a network attached memory),or any other appropriate page of memory. At 1804, the dormant page isallocated. At 1806, the allocated dormant page is then zeroed. In someembodiments, the zeroing of the dormant page is performed in parallelwith the allocation of the dormant page. An entry may then be placed ina second level page table, where the page becomes valid and non-dormant.As described above, by using dormant pages (where pages can be tagged asdormant) performing zeroing after (or at the time of/in parallel with)allocation increases the boot up speed of a system, as the zeroing isnot done at startup, but in a “lazy” fashion at the time that the pageis used.

Described above are techniques for attaching a network-attached memory(e.g., flash appliance) to a tightly coupled cluster of nodes in whichthe total memory of the cluster represents the memory of a virtualmachine supporting strong memory coherency. In some embodiments, asdescribed above, the network-attached memory within the cluster is thereference memory of the virtual machine.

Although the foregoing embodiments have been described in some detailfor purposes of clarity of understanding, the invention is not limitedto the details provided. There are many alternative ways of implementingthe invention. The disclosed embodiments are illustrative and notrestrictive.

What is claimed is:
 1. A computer system, comprising: a plurality ofphysically interconnected computing nodes, wherein a guest operatingsystem is run on a virtual environment that is defined by a set ofhyper-kernels running on at least a portion of the physicallyinterconnected computing nodes; a network-attached memory comprising acentralized appliance including an array of physical memory, wherein thenetwork-attached memory communicates with at least some of thephysically interconnected computing nodes over a network according to acoherency protocol; wherein, in response to a remote read request madeby a first computing node to a second computing node that has a primarycopy of a page of memory, the second computing node, according to thecoherency protocol: transitions the copy of the page of memory on thesecond computing node from being designated as a primary copy to beingdesignated as a secondary copy; performs a first transmission of a copyof the page of memory to the first computing node, wherein the copy ofthe page of memory on the first computing node is marked as primary, andwherein the page of memory is subsequently requested from the firstcomputing node based at least in part on the copy of the page of memoryon the first computing node being marked as primary; and performs asecond transmission of a copy of the page of memory to the centralizednetwork-attached memory, wherein the copy of the page of memory on thenetwork-attached memory is marked as valid and secondary.
 2. Thecomputer system of claim 1 wherein portions of the physical memory inthe network-attached memory correspond to guest physical addresses inthe virtual environment that is defined by the set of hyper-kernelsrunning on the at least portion of the physically interconnectedcomputing nodes.
 3. The computer system of claim 1 wherein based atleast in part on detection of a failure, the network-attached memoryrequests copies of one or more pages from the computing nodes in theplurality of physically interconnected computing nodes.
 4. The computersystem of claim 3 wherein the one or more pages for which copies arerequested comprise pages determined to be invalid on thenetwork-attached memory.
 5. The computer system of claim 4 wherein thenetwork-attached memory updates an invalid page with a correspondingobtained copy of a requested page.
 6. The computer system of claim 1wherein the network-attached memory includes at least one of flashmemory, phase change memory, and 3D-Xpoint memory.
 7. The computersystem of claim 1 wherein the network-attached memory stores a read-onlycopy of the page.
 8. A method, comprising: according to a coherencyprotocol, in response to a remote read request made by a first computingnode in a plurality of physically interconnected computing nodes to asecond computing node that has a primary copy of a page of memory:transitioning, by the second computing node, the copy of the page ofmemory on the second computing node from being designated as a primarycopy to being designated as a secondary copy; performing a firsttransmission, from the second computing node, of a copy of the page ofmemory to the first computing node, wherein the copy of the page ofmemory on the first computing node is marked as primary, and wherein thepage of memory is subsequently requested from the first computing nodebased at least in part on the copy of the page of memory on the firstcomputing node being marked as primary; and performing a secondtransmission, from the second computing node, of a copy of the page ofmemory to a centralized network-attached memory comprising a centralizedappliance including an array of physical memory, wherein the copy of thepage of memory on the network-attached memory is marked as valid andsecondary; and wherein a guest operating system is run on a virtualenvironment that is defined by a set of hyper-kernels running on atleast a portion of the physically interconnected computing nodes, andwherein the network-attached memory communicates with at least some ofthe physically interconnected computing nodes over a network accordingto the coherency protocol.
 9. A computer program product embodied in anon-transitory computer readable storage medium and comprising computerinstructions for: according to a coherency protocol, in response to aremote read request made by a first computing node in a plurality ofphysically interconnected computing nodes to a second computing nodethat has a primary copy of a page of memory: transitioning, by thesecond computing node, the copy of the page of memory on the secondcomputing node from being designated as a primary copy to beingdesignated as a secondary copy; performing a first transmission, fromthe second computing node, of a copy of the page of memory to the firstcomputing node, wherein the copy of the page of memory on the firstcomputing node is marked as primary, and wherein the page of memory issubsequently requested from the first computing node based at least inpart on the copy of the page of memory on the first computing node beingmarked as primary; and performing a second transmission, from the secondcomputing node, of a copy of the page of memory to a centralizednetwork-attached memory comprising a centralized appliance including anarray of physical memory, wherein the copy of the page of memory on thenetwork-attached memory is marked as valid and secondary; and wherein aguest operating system is run on a virtual environment that is definedby a set of hyper-kernels running on at least a portion of thephysically interconnected computing nodes, and wherein thenetwork-attached memory communicates with at least some of thephysically interconnected computing nodes over a network according tothe coherency protocol.